#!/bin/sh
KEYSTORE=keystore
TRUSTSTORE=truststore
echo "Creating key for alias $1 ..."
keytool -genkeypair -keyalg RSA -validity 7 -keystore $KEYSTORE -dname "CN=$1,OU=server,O=xeerkat,C=US" -alias $1 
echo "Exporting alias $1 ..."
keytool -export -file $1.cer -keystore $KEYSTORE -alias $1
echo "Importing alias $1 into truststore ..."
keytool -import -v -trustcacerts -file $1.cer -keystore $TRUSTSTORE -alias $1
echo "Done."
